/*
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

*/

#ifndef SCENE_MATERIAL_H
#define SCENE_MATERIAL_H

#include <iostream>
#include "scenemanager/sceneelement.h"

using namespace std;

#include "objects/vertex.h"

namespace scene {

  /*
  * Type: 0 = DIFFUSE
  * Type: 1 = PHONG
  * Type= 2 = LINEAR COMBINATION
  */
class Material : public SceneElement
{
  public:
    Material(object::Vertex * color, int type):m_color(color), m_type(type),
m_reflect(false), m_refract(false), m_specColor(NULL),m_glossy(false){;}
    Material(int type):m_color(NULL), m_type(type),
m_reflect(false), m_refract(false), m_specColor(NULL){;}
    ~Material(){
      delete m_color; 
      if(m_specColor != NULL)
        delete m_specColor;
    }
    virtual void printElement()
    {
      cout << "MaterialInfo: ";
      cout << m_name.toStdString() << "\n";
      m_color->print();
    }
    
    inline object::Vertex * color(){return m_color;}
    inline object::Vertex * specColor(){return m_specColor;}
    inline void setShinyness(int exp){m_shinyness = exp;}
    inline int shinyExp(){return m_shinyness;}
    inline int type(){return m_type;}
    
    inline void setReflect(bool val){m_reflect = val;}
    inline void setRefract(bool val){m_refract = val;}
    inline void setSpecularColor(object::Vertex * val){m_specColor = val;}
    
    inline bool reflect(){return m_reflect;}
    inline bool refract(){return m_refract;}
    
    inline void setMat1(Material *val){m_mat1 = val;}
    inline void setMat2(Material *val){m_mat2 = val;}
    inline Material* getMat1(){return m_mat1;}
    inline Material* getMat2(){return m_mat2;}
    
    inline void setWeight1(float val){m_mat1PC = val;}
    inline void setWeight2(float val){m_mat2PC = val;}
    inline float getWeight1(){return m_mat1PC;}
    inline float getWeight2(){return m_mat2PC;}
    
    inline void setGlossyFactor(float val){m_glossyFac = val;m_glossy = true;}
    inline float glossyFactor(){return m_glossyFac;}
    inline bool glossy(){return m_glossy;}
    
  private:
    object::Vertex * m_color;
    int m_type;
    int m_shinyness;
    
    bool m_reflect;
    bool m_refract;
    
    Material *m_mat1;
    float m_mat1PC; // percentage of mat 1
    Material *m_mat2;
    float m_mat2PC; // percentage of mat 2
    
    object::Vertex * m_specColor;
    
    float m_glossyFac;
    bool m_glossy;
};

}

#endif // SCENE_MATERIAL_H
